Local list1=NewList()
	AddLast(list1,"abcd")
	AddLast(list1,"djkq")
	AddLast(list1,"abc")
	AddLast(list1,"bbcd")
	
	SortList list1,1

Print "- Sort List 1 ASC -"
PrintList list1
Print "------------"

Local list2=NewList()
	AddLast(list2,"001")
	AddFirst(list2,"003")
	AddLast(list2,"004")
	AddLast(list2,"002")
	; result : 3,1,4,2
	
	SortList list2,-1
	; result : 4,3,2,1
	
	Local l1=AfterLink(ListFirst(list2))
	; result : l1 = link("003")
	
	InsertAfter(l1,ListContains(list2,"001")) ; insert l1 after "001"
	; result : 4,2,1,3
	
	SwapLinks ListContains(list2,"002"),ListContains(list2,"004")
	; result : 2,4,1,3
	
	SwapLinks ListContains(list2,"004"),ListContains(list2,"003")
	; result : 2,3,1,4
	
	InsertBefore ListContains(list2,"001"),ListContains(list2,"002")
	; result : 1,2,3,4
	
Print "- Sort List 2 DESC then manipulate links -"
PrintList list2

	SetLinkValue ListFirst(list2),"First"
	SetLinkValue AfterLink(ListFirst(list2)),"Second"
	SetLinkValue BeforeLink(ListLast(list2)),"Third"
	SetLinkValue ListLast(list2),"Fourth"

Print "- Modify values of links in List 2 -"
PrintList list2
Print "- Remove Second Link from list2 -"
DeleteLink ListContains(list2,"Second")
PrintList list2
Print "------------"

Local list3=NewList()
	SeedRnd 1
	Local CountObjects=500
	For n=1 To CountObjects
		AddLast(list3,"Objet "+Str(Rand(1,10000)))
	Next
	Local t0=MilliSecs()
	SortList list3,1
	Local t1=MilliSecs()

Print "- List 3 contains '"+CountObjects+"' objects -"
Print "  time to sort the list : "+(t1-t0)+" ms"

DeleteList(list1)
DeleteList(list2)
DeleteList(list3)

WaitKey
End

Function PrintList(List)
	Local l1=ListFirst(List)
	While l1<>0
		Print "   * "+LinkValue(l1)
		l1=AfterLink(l1)
	Wend
End Function
;~IDEal Editor Parameters:
;~C#Blitz3D